package dp;

public class TwoKeysKeyboard650 {
    public int minSteps(int n) {
        if(n<=1){
            return 0;
        }
        int[] dp = new int[n+1];
        for (int i = 0; i < dp.length; i++) {
            dp[i]=Integer.MAX_VALUE;
        }
        dp[1] =0;
        for (int i = 2; i < n + 1; i++) {
            for (int j = i;  j>0; j--) {
                if(i%j==0){
                    dp[i]=Math.min(dp[i],j+dp[i/j]);
                }
            }
        }
        return dp[n];
    }
}
